package org.example.diet_compass.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.example.diet_compass.domain.Banners;
import org.example.diet_compass.domain.Categories;
import org.example.diet_compass.domain.Goods;
import org.example.diet_compass.resp.Result;
import org.example.diet_compass.resp.ResultCodeEnum;
import org.example.diet_compass.service.BannersService;
import org.example.diet_compass.service.CategoriesService;
import org.example.diet_compass.service.GoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author Archer_hui
 * @version 1.0
 * @Date 2025/2/27 16:31
 */
@Tag(name = "首页接口文档")
@RestController
@RequestMapping("/home")
public class HomeController {
    @Resource
    private BannersService bannersService;

    @GetMapping("/banner")
    @Operation(summary = "获取Swpier")
    public Result<List<Banners>> getHomeBanner(Integer type) {
        List<Banners> banners = bannersService.getBanners(type);
        return Result.build(banners, ResultCodeEnum.SUCCESS);
    }

    @Resource
    private CategoriesService categoriesService;

    @GetMapping("/categories/multi")
    @Operation(summary = "获取分类")
    public Result<List<Categories>> getHomeCategories() {
        List<Categories> categoriesList = categoriesService.list();
        return Result.build(categoriesList, ResultCodeEnum.SUCCESS);
    }

    @Resource
    private GoodsService goodsService;

    @GetMapping("/goods/recommendAll")
    @Operation(summary = "获取全部推荐商品")
    public Result<List<Goods>> getHomeGoods() {
        List<Goods> goodsList = goodsService.getRecommendsOrderByAVGScore();
        return Result.build(goodsList, ResultCodeEnum.SUCCESS);
    }



}
